﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DalatCooking.Core
{
    public class SecurityServices
    {
        public enum TypeAudit
        {
            View = 1,
            Add = 2,
            Delete = 4,
            Edit = 8,
            Register = 16,
            Editor = 32,
            Manager = 64,
            Administrator = 128,
            SuperUser = 256
        }

        public static bool HasPermission(TypeAudit audit, int roleNumber)
        {
            if (((int)audit & roleNumber) == (int)audit)
                return true;
            return false;
        }
        public static bool HasPermission(string rightName, int personId, TypeAudit audit)
        {
            /*
            PersonRole personRole = PersonRoleManager.FindByPersonId(personId);
            if ((personRole != null) && personRole.Role.ToLower() == rightName)
                return HasPermission(audit, personRole.RoleNumber);
            return false;
             * */
            return false;
        }
        protected ArrayList roleList;
        public bool IsInRole(string role)
        {
            return roleList.Contains(role);
        }
        public ArrayList Roles
        {
            get { return roleList; }
        }
    }
}

/*
 * GetAllRightByRole: select * from RightRole where Role = Role
 * If HasRight == Right AllowAction
 * Else Deny
 * 
 */
